package com.xh.demo.feign;

import com.xh.demo.commons.model.response.R;
import com.xh.demo.feign.config.FeignInterceptor;
import com.xh.demo.feign.fallback.OrderFeignFallback;
import com.xh.demo.model.request.OrderCreateRequest;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author wen
 * @apiNote OrderServiceFeign
 * @since 2021-12-10
 */
@FeignClient(
        name = "order-center",
        contextId = "order-core",
        path = "/core",
        fallbackFactory = OrderFeignFallback.class,
        configuration = {FeignInterceptor.class}
)
public interface OrderServiceFeign {

    @GetMapping("/v1/detail/{id}")
    R<String> detail(@PathVariable("id") Long id);

    @GetMapping("/v2/detail/{id}")
    R<String> detailV2(@PathVariable("id") Long id);

    @GetMapping("/v3/detail/{id}")
    R<String> detailV3(@PathVariable("id") Long id);

    @PostMapping("/v1/order/{sku-id}")
    R<String> create(@PathVariable("sku-id") Long skuId,
                     @RequestBody OrderCreateRequest request);

}
